﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>判断js类型函数实现</title>
</head>
<body>
    <script type="text/javascript">
        function type (arg) {
            var type = Object.prototype.toString.call(arg)
            var flag = type.replace('[', '').replace(']', '').split(' ')[ 1 ]
            return {
                [ 'is' + flag ]: true
            }
        }
        // 这样比较灵活判断
    </script>
</body>
</html>